package com.qf.factory;

import java.util.Properties;

public class MyFactory {
    private Properties properties = new Properties();

    public MyFactory(String config)throws  Exception{
        //加载配置文件
        properties.load(MyFactory.class.getResourceAsStream(config));
    }
    //获取对象
    public Object getBean(String beanName) throws Exception{
        String classPath = properties.getProperty(beanName);
        if (classPath !=null){
            Class clazz = Class.forName(classPath);
            return clazz.newInstance();
        }
        return  null;
    }


}
